#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,v;
int d[100008],a[100008],v0[100008],p[100008],dp[100008];
double vt(int s0,int st,int vx,int a0)
{
	int x=st-s0;
	double ans=sqrt(vx*vx+2*a0*x);
	return ans;
	}
int main()
{
	/*freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);*/
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d%d",&n,&m,&l,&v);
		memset(d,0,sizeof(d));
		memset(a,0,sizeof(a));
		memset(v0,0,sizeof(v0));
		memset(p,0,sizeof(p));
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d%d",&d[i],&v0[i],&a[i]);
			}
			for(int i=1;i<=m;i++)
			{
				scanf("%d",&p[i]);
				}
		for(int i=1;i<=n;i++)
		{
			int k=0;
			for(int j=1;j<=m;j++)
			{
				if(d[i]<=p[j]&&vt(d[i],p[j],v0[i],a[i])>v)
				{
					k=1;
					}
				}
				if(k==1)
				{
					ans++;
					}
			}
			printf("%d",ans);		
		}
	return 0;
	}
